<%= grid(data_types) do |g|
    g.action_column  object_property: :id
   
    g.column name: '名称', attribute: 'name' do |data_type|
      if data_type.sup
        link_to data_type.name, "/#{data_type.code+"es"}"
      else
        link_to data_type.name, subs_data_type_path(data_type)
      end
     
    end

    g.column name: '缩写', attribute: 'code' do |data_type|
       data_type.code
    end

    g.column name: '上级分类', attribute: 'sup_id' do |data_type|
      data_type.sup.name if data_type.sup
    end

    g.column name: '信息分组', attribute: 'group_name' do |data_type|
       data_type.group_name
    end
   
    g.column name: '下级分类(个)', attribute: 'subs_count' do |data_type|
      link_to data_type.subs_count, subs_data_type_path(data_type)
    end

    g.column name: '创建时间',attribute: 'created_at'  do |data_type|
      time_str data_type.created_at
    end

    g.column name: '最后修改时间',attribute: 'updated_at'  do |data_type|
      time_str data_type.updated_at
    end

    g.column do |data_type| 
      link_to('编辑',edit_data_type_path(data_type),:class=>'')+"        "+
      link_to('删除',data_type,:class=>'', method: :delete, data: { confirm: 'Are you sure?' })
    end
   
end %>
